package com.gateon.hw.system.controller;
import com.gateon.hw.client.system.client.SupplierContractService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.gateon.hw.client.system.resp.SupplierContractResp;
import com.gateon.hw.client.system.req.SupplierContractListReq;
import com.gateon.hw.client.system.req.SupplierContractAddReq;
import com.gateon.hw.client.system.req.SupplierContractUpdateReq;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import com.gateon.hw.base.vo.Result;
import com.baomidou.mybatisplus.core.metadata.IPage;

/**
*  合同信息表 Controller层
* Created by leslie on 2020-4-29 15:38:04
*/
@Api(tags = "合同信息表")
@RestController
@RequestMapping(value = "/supplierContract")
public class SupplierContractController{

    @Autowired
    private ISupplierContractService supplierContractService;

    @ApiOperation(value = "查询合同信息表", notes = "查询合同信息表")
    @ApiImplicitParams({
    @ApiImplicitParam(paramType = "header", name = "X-Token", value = "用户登录信息", required = true, dataType = "String"),
    @ApiImplicitParam(name = "req", value = "查询合同信息表-请求封装类", required = true, dataType = "SupplierContractListReq")
    })
    @RequestMapping(value = "/list", method = RequestMethod.POST)
    public ResultModel<IPage<SupplierContractResp>> list(@RequestBody SupplierContractListReq req) {
        return supplierContractService.list(req);
    }

    @ApiOperation(value = "查询合同信息表详情", notes = "查询合同信息表详情")
    @ApiImplicitParams({
    @ApiImplicitParam(name = "id", value = "合同信息表ID", required = true,  paramType = "path",dataType = "int")
    })
    @RequestMapping(value = "/{id}", method = RequestMethod.GET)
    public ResultModel<SupplierContractResp> getById(@PathVariable("id") Long id) {
        return supplierContractService.detail(id);
    }

    @ApiOperation(value = "添加合同信息表", notes = "添加合同信息表")
    @ApiImplicitParams({
    @ApiImplicitParam(name = "req", value = "添加合同信息表-请求封装类", required = true, dataType = "SupplierContractAddReq")
    })
    @RequestMapping(value = "/add", method = RequestMethod.POST)
    public ResultModel insert(@RequestBody SupplierContractAddReq req) {
        return supplierContractService.insert(req);
    }


    @ApiOperation(value = "更新合同信息表", notes = "更新合同信息表")
    @ApiImplicitParams({
    @ApiImplicitParam(name = "req", value = "更新合同信息表-请求封装类", required = true, dataType = "SupplierContractUpdateReq")
    })
    @RequestMapping(value = "/update", method = RequestMethod.POST)
    public ResultModel update(@RequestBody SupplierContractUpdateReq req) {
        return supplierContractService.update(req);
    }

    @RequestMapping(value = "{id}", method = RequestMethod.DELETE)
    @ApiOperation(value = "删除合同信息表", notes = "删除合同信息表")
    @ApiImplicitParams({
    @ApiImplicitParam(name = "id", value = "合同信息表ID", required = true,  paramType = "path",dataType = "int")
    })
    public ResultModel delete(@PathVariable("id") Long id) {
        return supplierContractService.delete(id);
    }

}
